package com.zx.erp.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zx.erp.sys.bean.Module;
import com.zx.erp.sys.bean.Users;
import com.zx.erp.sys.mapper.ModuleMapper;
import com.zx.erp.sys.service.ModuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author 郑攀武
 * @since 2021-11-10
 */
@Service
public class ModuleServiceImpl extends ServiceImpl<ModuleMapper, Module> implements ModuleService {
    @Autowired
    private ModuleMapper mapper;

    @Override
    public List<Module> findAllParentModule(Integer jobId) {

        return mapper.findAllParentModule(jobId);
    }

    @Override
    public List<Module> selectAllModule(Integer jobId) {
        return mapper.selectAllModule(jobId);
    }

    @Override
    public List<Module> selectAllModule2(String mname, Integer mState) {
        QueryWrapper<Module> wrapper = new QueryWrapper<Module>();
        wrapper.like("MODULE_RNAME", mname).eq("MODULE_STATE", mState);
        List<Module> list = list(wrapper);
        return list;
    }

    @Override
    public List<Module> findAllParentModule2(Integer pstate) {
        QueryWrapper<Module> wrapper = new QueryWrapper<Module>();
        wrapper.eq("MODULE_STATE", pstate).eq("MODULE_PID", 0);
        List<Module> list = list(wrapper);
        return list;
    }

    @Override
    public Page<Module> moduleAll(Module module, Integer pageNo, Integer pageSize) {

        Page<Module> page=new Page<Module>(pageNo,pageSize);
        Page<Module> modulePage = mapper.moduleAll(page, module);
        return modulePage;

    }

    /*查父模块*/
    public  List<Module> findParentModule(){
        return mapper.findParentModule();
    }
    /*根据id查模块*/
    public Module seModuleById(Integer moduleId){
        return mapper.seModuleById(moduleId);
    }

    @Override
    public boolean addModule(Module module){
        boolean b = mapper.addModule(module);
        return b;

    }

    /*修改*/
    public boolean updateModule(Module module){
        boolean b = mapper.updateModule(module);
        return b;
    }
}
